<template>
  <div class="hello">
    <Son v-bind:users="users"></Son>
    <h1>{{ msg }}</h1>


    <!--与子组件titleChanged自定义事件保持一致-->
    <app-header v-on:titleChanged="updateTitle"></app-header>
    <!--     updateTitle($event)接受传递过来的文字-->
    <h2>{{ title }}</h2>

  </div>
</template>

<script>
import Header from "@/components/Header"
import Son from "@/components/Son"

export default {
  name: 'HelloWorld',

  data() {
    return {
      msg: 'Welcome to Your Vue.js App',
      users: ["Henry", "Bucky", "Emily"],
      title: "传递的是一个值"
    }
  },

  created() {
    // this.getNotisList();
  },
  methods: {


    getNotisList() {
      this.$http.get('/list')
        .then(res => {
          console.log(res)
        })
        .catch(err => {
          console.log(err)
        })
    },


    updateTitle(e) {   //声明这个函数
      this.title = e;
    }

  },

  components: {
    "Son": Son,
    "app-header": Header,
  }

}
</script>


<style scoped>

h2 {
  margin-top: 10px;
}

</style>
